home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1997 April
/
EnigmA AMIGA RUN 17 (1997)(G.R. Edizioni)(IT)[!][issue 1997-04][EAR-CD].iso
/
EARCD
/
comm
/
bbs
/
Hydra11s.lha
/
HBBS
/
Source
/
Doors_System
/
Hack
/
Main.C
< prev
next >
Wrap
C/C++ Source or Header
|
1996-10-31
|
4KB
|
217 lines
/* **** HBBS Door Code****************************************************** */
/*
Hack
====
This is called by frontend
Version
=======
1.0
Options
=======
N_ND->ActiveDoor->SystemOptions
-------------------------------
none
Command Line Arguments
----------------------
2 PSWD | LOCK | TIME
3 <Username>
ToDo
====
Finish It
*/
/* **** Includes *********************************************************** */
#include <exec/types.h>
#include <exec/memory.h>
#include <dos/dos.h>
#include <clib/exec_protos.h>
#include <clib/dos_protos.h>
#include <clib/alib_protos.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <ctype.h>
#include <time.h>
#include <HBBS/ANSI_Codes.h>
#include <HBBS/Defines.h>
#include <HBBS/Access.h>
#include <HBBS/types.h>
#include <HBBS/structures.h>
#include <HBBS/hbbscommon_protos.h>
#include <HBBS/hbbscommon_pragmas.h>
#include <HBBS/Hbbsnode_protos.h>
#include <HBBS/Hbbsnode_pragmas.h>
#include <HBBS/release.h>
char *versionstr="$VER: Hack "RELEASE_STR;
/* **** Variables ********************************************************** */
struct Library *HBBSCommonBase = NULL;
struct Library *HBBSNodeBase = NULL;
struct BBSGlobalData *BBSGlobal = NULL;
struct NodeData *N_ND = NULL;
int N_NodeNum = -1;
char outstr[1024];
long __stack=16*1024; // increse this in 4k incrments if you suffer from
// random/suprious crashings after or during the running
// of your door.
int gargc; // these are just copies of main()'s argc and argv..
char **gargv;
/* **** Functions ********************************************************** */
#ifdef __SASC
int CXBRK(void) { return(0); }
int _CXBRK(void) { return(0); }
void chkabort(void) {}
#endif
static VOID cleanup(ULONG num)
{
if (HBBSNodeBase)
{
HBBS_CleanUpDoor();
CloseLibrary (HBBSNodeBase);
}
if (HBBSCommonBase)
{
HBBS_CleanUpCommon();
CloseLibrary (HBBSCommonBase);
}
if (num) printf("Door Error = %d\n",num);
exit(0);
}
static VOID init(char *name)
{
if(!(HBBSCommonBase = OpenLibrary("HBBSCommon.library",0)))
{
cleanup(1);
}
if (!(HBBS_InitCommon()))
{
cleanup(2);
}
if(!(HBBSNodeBase = OpenLibrary("HBBSNode.library",0)))
{
cleanup(3);
}
if (!(HBBS_InitDoor(N_NodeNum,name)))
{
cleanup(4);
}
SetProgramName(name);
}
/* **** DoorMain *********************************************************** */
void DoorMain( void )
{
int loop;
BOOL Done=FALSE;
if (gargc<4)
{
DOOR_PausePrompt("Not Enough Parameters Passed to HACK door!");
}
else
{
// Get the username from the parameters
outstr[0]=0;
for(loop=3;loop<gargc;loop++)
{
if (loop!=3) strcat(outstr," ");
strcat(outstr,gargv[loop]);
}
DOOR_WriteText(ANSI_CLS);
sprintf(outstr,"HACK_%s",gargv[2]);
DOOR_DisplaySpecialScreen(outstr);
DOOR_WriteText(ANSI_RESET ANSI_FG_YELLOW );
while (N_ND->OnlineStatus==OS_ONLINE && !Done)
{
DOOR_MenuPrompt(ANSI_RESET "\r\nLeave a [C]omment, Page the [O]perator or [G]oodbye : ",' ');
strcpy(N_ND->CharsAllowed,"COGcog");
if (IN_TIMEOUT==DOOR_GetLine(GL_IMMEDIATE|GL_USECHARS,0,1,30,NULL))
{
Done=TRUE;
DOOR_WriteText("Timeout!, bye!!\r\n");
}
if (N_ND->OnlineStatus==OS_ONLINE && !Done)
{
DOOR_WriteText(N_ND->CurrentLine);
DOOR_WriteText("\r\n");
switch (toupper(N_ND->CurrentLine[0]))
{
case 'C':
DOOR_UserDoor("C",NULL);
break;
case 'O':
DOOR_UserDoor("O",NULL);
break;
case 'G':
Done=TRUE;
break;
}
}
}
DOOR_DisplaySpecialScreen("HACK_BYE");
}
}
int main(int argc,char **argv)
{
gargc=argc;
gargv=argv;
if (sscanf(argv[1],"%d",&N_NodeNum)==0)
{
printf("Invalid/No Paramaters for door!\n");
exit (20);
}
init("Hack");
if (BBSGlobal=HBBS_GimmeBBS())
{
if (N_ND=HBBS_NodeDataPtr(N_NodeNum)) // this should not fail in normal circumstances..
{
DoorMain();
}
}
cleanup(0);
}
/* **** End Of File ******************************************************** */